package com.flyee.controller.tools.sandtable {
	
	import alternativa.engine3d.core.*;
	import alternativa.engine3d.events.*;
	
	public class Building3D	{
		
		public var mesh : Mesh;
		
		public var id : String;
		public var name : String;
		public var info : String;
		private var estate : Estate3D;
		public var infoPanel : InfoPanel;
		
		public function Building3D(tid : String, tname : String, tinfo : String, testate : Estate3D) {
			id = tid;
			name = tname;
			info = tinfo;
//			mesh = testate;
			estate = testate;
//			mesh.addEventListener(MouseEvent3D.CLICK, onClickHandle);
		}
		
		public function initListener() : void {
//			mesh.addEventListener(MouseEvent3D.CLICK, onClickHandle);
		}
		
		private function onClickHandle(event : MouseEvent3D) : void {
			if(estate.selectBuilding!=null){// && estate.selectBuilding != this){
				estate.selectBuilding.changeBuildingAlpha(1);
				estate.selectBuilding.infoPanel.visible = false;
				estate.selectBuilding.infoPanel.parent.removeChild(estate.selectBuilding.infoPanel);
				estate.selectBuilding.infoPanel.dispose();
				estate.selectBuilding.infoPanel = null;
			}
			estate.selectBuilding = this;
			this.infoPanel = new InfoPanel();
			this.infoPanel.buildingInfo = this;
			this.estate.service.displayContainer.parent.addChild(this.infoPanel);
			infoPanel.x = this.estate.service.displayContainer.mouseX;
			infoPanel.y = this.estate.service.displayContainer.mouseY;
			changeBuildingAlpha(0.5);
		}
		
		public function changeBuildingAlpha(alpha : Number) : void {
			var surfaceList : Array = mesh.surfaces.toArray();
		 	for each(var sur : Surface in surfaceList){		
		 		sur.material.alpha = alpha;				
		 	}
		 	//其他弹出窗口操作
		 	//。。。。
		}
		
		public function dispose() : void {
//			mesh.removeEventListener(MouseEvent3D.CLICK, onClickHandle);
			mesh = null;
			id = null;
			name = null;
			info = null;
			estate = null;
			
		}

	}
}